package view.Tabs;

import java.util.List;

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.ProgressBar;
import org.eclipse.swt.widgets.ScrollBar;

import view.Windows.DateCalendarGUI;
import view.Windows.NewCommentGUI;
import view.Windows.ReviewPageGUI;

import commons.Entities.Comment;
import commons.Entities.LegenCharacter;
import commons.Entities.LegenCharacterThin;
import commons.Entities.Review;

import controller.ControllerFunctions;

public class CharacterGUI {

	// final public Shell shlMain;
	protected Color cBackgroundColor;
	protected Font fHeadFont;
	protected Font fLabelFont;
	protected Font fButtonFont;
	protected boolean selectedFavorite = false;
	protected Display mainDisp;
	protected LegenCharacter character;

	protected ScrolledComposite scCharacterProfile;
	protected Composite cCharacterProfile;
	protected ScrollBar sbCharacterProfile;
	protected ScrolledComposite scReviews;
	protected ScrolledComposite scComments;
	protected Composite cReviews;
	protected Composite cComments;
	protected ScrollBar sbReviews;
	protected ScrollBar sbComments;
	protected int commentsHeight;
	protected int i;
	protected Button btnFav;
	protected Button btnComment;

	public CharacterGUI(final Display mainDisp, Composite shlMain, final LegenCharacter character) {

		setMainDisp(mainDisp);
		setCharacter(character);
		initFonts(mainDisp);

		// check if this is a favorite character for that user
		for (LegenCharacterThin lctChar : ProfileGUI.get().getLctList()) {
			if ((int) lctChar.getCharacterID() == (int) character.getCharacterID()) {
				selectedFavorite = true;
				break;
			}
		}

		// main display for the login page
		shlMain.setBounds(10, 10, 900, 700);
		final Color clrWhite = new Color(mainDisp, 255, 255, 255);
		Image iBG = new Image(mainDisp, getClass().getClassLoader().getResourceAsStream("view/Assets/LegenDateBG2.jpg"));
		shlMain.setBackgroundMode(SWT.INHERIT_DEFAULT);
		shlMain.setBackgroundImage(iBG);

		// the favorite button
		final Image favStarEmpty = new Image(mainDisp, getClass().getClassLoader().getResourceAsStream("view/Assets/star5-none.png"));
		final Image favStarFull = new Image(mainDisp, getClass().getClassLoader().getResourceAsStream("view/Assets/star5-full.png"));
		btnFav = new Button(shlMain, 0);
		if (selectedFavorite)
			btnFav.setImage(favStarFull);
		else
			btnFav.setImage(favStarEmpty);

		btnFav.setBounds(820, 10, 50, 50);
		btnFav.setToolTipText("Add to favorites");
		btnFav.addSelectionListener(new SelectionAdapter() {

			@Override
			public void widgetSelected(SelectionEvent e) {
				if (!selectedFavorite) {
					btnFav.setImage(favStarFull);
					selectedFavorite = true;
					ControllerFunctions.get().addFavoriteToDB(HomePageGUI.get().getUser().getID(), character.getCharacterID());
				} else {
					btnFav.setImage(favStarEmpty);
					selectedFavorite = false;
					ControllerFunctions.get().removeFavoriteFromDB(HomePageGUI.get().getUser().getID(), character.getCharacterID());
				}
			}
		});

		// name
		Label lblCharacterName = new Label(shlMain, SWT.NONE);
		lblCharacterName.setText(character.getCharacterName());
		lblCharacterName.setBounds(50, 20, 500, 50);
		lblCharacterName.setFont(getHeadFont());
		lblCharacterName.setForeground(clrWhite);

		Composite compCharacterProfile = new Composite(shlMain, 0);
		compCharacterProfile.setBounds(50, 70, 820, 600);
		compCharacterProfile.setForeground(clrWhite);

		// details group
		Group grCharDetails = new Group(compCharacterProfile, SWT.V_SCROLL);
		grCharDetails.setBounds(5, 5, 500, 330);
		grCharDetails.setForeground(clrWhite);
		grCharDetails.setBackgroundMode(SWT.INHERIT_FORCE);
		scCharacterProfile = new ScrolledComposite(grCharDetails, SWT.V_SCROLL | SWT.RIGHT_TO_LEFT);
		scCharacterProfile.setBounds(2, 25, 490, 303);
		scCharacterProfile.setExpandVertical(true);
		cCharacterProfile = new Composite(scCharacterProfile, SWT.LEFT_TO_RIGHT);
		cCharacterProfile.setBounds(0, 0, 450, 1010);
		GridLayout glCharProfile = new GridLayout();
		glCharProfile.numColumns = 2;
		cCharacterProfile.setLayout(glCharProfile);
		sbCharacterProfile = scCharacterProfile.getVerticalBar();
		sbCharacterProfile.setVisible(true);

		Label lblCharDetails = new Label(compCharacterProfile, 0);
		lblCharDetails.setForeground(clrWhite);
		lblCharDetails.setText("Character Details");
		lblCharDetails.setBounds(15, 5, 120, 20);
		lblCharDetails.moveAbove(grCharDetails);
		lblCharDetails.setAlignment(SWT.CENTER);

		// set a date button
		Button btnSetDate = new Button(grCharDetails, SWT.NONE);
		// btnSetDate.setText("Set Date!");
		btnSetDate.setImage(new Image(mainDisp, getClass().getClassLoader().getResourceAsStream("view/Assets/car-art-calendar-free.png")));
		btnSetDate.setToolTipText("Set a Date!");
		btnSetDate.setBounds(434, 12, 64, 64);
		btnSetDate.moveAbove(scCharacterProfile);
		btnSetDate.addSelectionListener(new SelectionAdapter() {

			@Override
			public void widgetSelected(SelectionEvent e) {
				DateCalendarGUI setDatePopup = new DateCalendarGUI(mainDisp, HomePageGUI.get().getUser().getID(), character.getCharacterID());
				setDatePopup.showGUI(mainDisp);
				return;

			}
		});

		i = 0;

		// characterCreatedBy
		if (character.getCharacterCreatedBy() != null) {
			GridData labelGridData = new GridData();
			labelGridData.verticalAlignment = SWT.TOP;

			String createdBy = character.getCharacterCreatedBy();
			int j = 1 + createdBy.length()/40;
			Label lblCreatedBy = new Label(cCharacterProfile, 0);
			lblCreatedBy.setText("Created By: ");
			lblCreatedBy.setBounds(10, 20 + 30 * i, 120, 20);
			lblCreatedBy.setForeground(clrWhite);
			lblCreatedBy.setLayoutData(labelGridData);

			GridData detailsGridData = new GridData();
			detailsGridData.widthHint = 250;
			detailsGridData.verticalAlignment = SWT.TOP;
			
			Label txCreatedBy = new Label(cCharacterProfile, SWT.WRAP);
			txCreatedBy.setText(createdBy);
			txCreatedBy.setBounds(180, 20 + 30 * i, 300, 20*j);
			txCreatedBy.setForeground(clrWhite);
			txCreatedBy.setLayoutData(detailsGridData);

			i += j;
		}

		// based on
		if (character.getBasedOn() != null) {
			GridData labelGridData = new GridData();

			labelGridData.verticalAlignment = SWT.TOP;
			Label lblBasedOn = new Label(cCharacterProfile, 0);
			lblBasedOn.setText("based on: ");
			lblBasedOn.setBounds(10, 20 + 30 * i, 130, 20);
			lblBasedOn.setForeground(clrWhite);
			lblBasedOn.setLayoutData(labelGridData);

			GridData detailsGridData = new GridData();
			detailsGridData.widthHint = 250;
			detailsGridData.verticalAlignment = SWT.TOP;
			
			Label txBasedOn = new Label(cCharacterProfile, SWT.WRAP);
			txBasedOn.setText(character.getBasedOn());
			txBasedOn.setBounds(180, 20 + 30 * i, 300, 20);
			txBasedOn.setForeground(clrWhite);
			txBasedOn.setLayoutData(detailsGridData);

			i++;
		}

		// POB
		if (character.getPlaceOfBirth() != null) {
			GridData labelGridData = new GridData();
			labelGridData.verticalAlignment = SWT.TOP;

			Label lblPOB = new Label(cCharacterProfile, 0);
			lblPOB.setText("Place Of Birth: ");
			lblPOB.setBounds(10, 20 + 30 * i, 130, 20);
			lblPOB.setForeground(clrWhite);
			lblPOB.setLayoutData(labelGridData);

			GridData detailsGridData = new GridData();
			detailsGridData.widthHint = 250;
			detailsGridData.verticalAlignment = SWT.TOP;
			
			Label txPOB = new Label(cCharacterProfile, SWT.WRAP);
			txPOB.setText(character.getPlaceOfBirth());
			txPOB.setBounds(180, 20 + 30 * i, 300, 20);
			txPOB.setForeground(clrWhite);
			txPOB.setLayoutData(detailsGridData);

			i++;
		}

		// gender
		if (character.getGender() != null) {
			GridData labelGridData = new GridData();
			labelGridData.verticalAlignment = SWT.TOP;

			Label lblGender = new Label(cCharacterProfile, 0);
			lblGender.setText("Gender: ");
			lblGender.setBounds(10, 20 + 30 * i, 130, 20);
			lblGender.setForeground(clrWhite);
			lblGender.setLayoutData(labelGridData);

			GridData detailsGridData = new GridData();
			detailsGridData.widthHint = 250;
			detailsGridData.verticalAlignment = SWT.TOP;
			
			Label txGender = new Label(cCharacterProfile, SWT.WRAP);
			txGender.setText(character.getGender());
			txGender.setBounds(180, 20 + 30 * i, 300, 20);
			txGender.setForeground(clrWhite);
			txGender.setLayoutData(detailsGridData);

			i++;
		}

		// species
		if (character.getSpecies() != null) {
			GridData labelGridData = new GridData();
			labelGridData.verticalAlignment = SWT.TOP;

			Label lblSpecies = new Label(cCharacterProfile, 0);
			lblSpecies.setText("Species: ");
			lblSpecies.setBounds(10, 20 + 30 * i, 130, 20);
			lblSpecies.setForeground(clrWhite);
			lblSpecies.setLayoutData(labelGridData);

			GridData detailsGridData = new GridData();
			detailsGridData.widthHint = 250;
			detailsGridData.verticalAlignment = SWT.TOP;
			
			Label txSpecies = new Label(cCharacterProfile, SWT.WRAP);
			txSpecies.setText(character.getSpecies());
			txSpecies.setBounds(180, 20 + 30 * i, 300, 20);
			txSpecies.setForeground(clrWhite);
			txSpecies.setLayoutData(detailsGridData);

			i++;
		}

		// Parents
		if (character.getParents() != null) {
			GridData labelGridData = new GridData();
			labelGridData.verticalAlignment = SWT.TOP;

			Label lblParents = new Label(cCharacterProfile, 0);
			lblParents.setText("Parents: ");
			lblParents.setBounds(10, 20 + 30 * i, 130, 20);
			lblParents.setForeground(clrWhite);
			lblParents.setLayoutData(labelGridData);

			GridData detailsGridData = new GridData();
			detailsGridData.widthHint = 250;
			detailsGridData.verticalAlignment = SWT.TOP;
			
			Label txParents = new Label(cCharacterProfile, SWT.WRAP);
			txParents.setText(character.getParents());
			txParents.setBounds(180, 20 + 30 * i, 300, 20);
			txParents.setForeground(clrWhite);
			txParents.setLayoutData(detailsGridData);

			i++;
		}

		// Occupation
		if (character.getOccupation() != null) {
			GridData labelGridData = new GridData();
			labelGridData.verticalAlignment = SWT.TOP;

			Label lblOccupation = new Label(cCharacterProfile, 0);
			lblOccupation.setText("Occupation: ");
			lblOccupation.setBounds(10, 20 + 30 * i, 130, 20);
			lblOccupation.setForeground(clrWhite);
			lblOccupation.setLayoutData(labelGridData);

			GridData detailsGridData = new GridData();
			detailsGridData.widthHint = 250;
			detailsGridData.verticalAlignment = SWT.TOP;
			
			Label txOccupation = new Label(cCharacterProfile, SWT.WRAP);
			txOccupation.setText(character.getOccupation());
			txOccupation.setBounds(180, 20 + 30 * i, 300, 20);
			txOccupation.setForeground(clrWhite);
			txOccupation.setLayoutData(detailsGridData);

			i++;
		}

		// Rank
		if (character.getRank() != null) {
			GridData labelGridData = new GridData();
			labelGridData.verticalAlignment = SWT.TOP;

			Label lblRank = new Label(cCharacterProfile, 0);
			lblRank.setText("Rank: ");
			lblRank.setBounds(10, 20 + 30 * i, 130, 20);
			lblRank.setForeground(clrWhite);
			lblRank.setLayoutData(labelGridData);

			GridData detailsGridData = new GridData();
			detailsGridData.widthHint = 250;
			detailsGridData.verticalAlignment = SWT.TOP;
			
			Label txRank = new Label(cCharacterProfile, 0);
			txRank.setText(character.getRank());
			txRank.setBounds(180, 20 + 30 * i, 300, 20);
			txRank.setForeground(clrWhite);
			txRank.setLayoutData(detailsGridData);

			i++;
		}

		// Organizations
		if (character.getOrganizations() != null) {
			GridData labelGridData = new GridData();
			labelGridData.verticalAlignment = SWT.TOP;

			Label lblOrganizations = new Label(cCharacterProfile, 0);
			lblOrganizations.setText("Organizations: ");
			lblOrganizations.setBounds(10, 20 + 30 * i, 130, 20);
			lblOrganizations.setForeground(clrWhite);
			lblOrganizations.setLayoutData(labelGridData);

			GridData detailsGridData = new GridData();
			detailsGridData.widthHint = 250;
			detailsGridData.verticalAlignment = SWT.TOP;
			
			Label txOrganizations = new Label(cCharacterProfile, 0);
			txOrganizations.setText(character.getOrganizations());
			txOrganizations.setBounds(180, 20 + 30 * i, 300, 20);
			txOrganizations.setForeground(clrWhite);
			txOrganizations.setLayoutData(detailsGridData);

			i++;
		}

		// Powers/Abilities
		if (character.getPowersOrAbilities() != null) {
			GridData labelGridData = new GridData();
			labelGridData.verticalAlignment = SWT.TOP;
			
			Label lblPowersOrAbilities = new Label(cCharacterProfile, 0);
			lblPowersOrAbilities.setText("Powers/Abilities: ");
			lblPowersOrAbilities.setBounds(10, 20 + 30 * i, 130, 20);
			lblPowersOrAbilities.setForeground(clrWhite);
			lblPowersOrAbilities.setLayoutData(labelGridData);

			GridData detailsGridData = new GridData();
			detailsGridData.widthHint = 250;
			detailsGridData.verticalAlignment = SWT.TOP;
			
			Label txPowersOrAbilities = new Label(cCharacterProfile, SWT.WRAP);
			txPowersOrAbilities.setText(character.getPowersOrAbilities());
			txPowersOrAbilities.setBounds(180, 20 + 30 * i, 200, 20);
			txPowersOrAbilities.setForeground(clrWhite);
			txPowersOrAbilities.setLayoutData(detailsGridData);
			i++;
		}

		// fictional universes
		if (character.getAppearsInTheseFictionalUniverses() != null) {
			GridData labelGridData = new GridData();
			labelGridData.verticalAlignment = SWT.TOP;

			Label lblFictionalUniverses = new Label(cCharacterProfile, 0);
			lblFictionalUniverses.setText("Fictional Universes: ");
			lblFictionalUniverses.setBounds(10, 20 + 30 * i, 130, 20);
			lblFictionalUniverses.setForeground(clrWhite);
			lblFictionalUniverses.setLayoutData(labelGridData);

			GridData detailsGridData = new GridData();
			detailsGridData.widthHint = 250;
			detailsGridData.verticalAlignment = SWT.TOP;
			
			Label txFictionalUniverses = new Label(cCharacterProfile, SWT.WRAP);
			txFictionalUniverses.setText(character.getAppearsInTheseFictionalUniverses());
			txFictionalUniverses.setBounds(180, 20 + 30 * i, 300, 20);
			txFictionalUniverses.setForeground(clrWhite);
			txFictionalUniverses.setLayoutData(detailsGridData);

			i++;
		}

		// children
		if (character.getChildren() != null) {
			GridData labelGridData = new GridData();
			labelGridData.verticalAlignment = SWT.TOP;

			Label lblChildren = new Label(cCharacterProfile, 0);
			lblChildren.setText("Children: ");
			lblChildren.setBounds(10, 20 + 30 * i, 160, 20);
			lblChildren.setForeground(clrWhite);
			lblChildren.setLayoutData(labelGridData);

			GridData detailsGridData = new GridData();
			detailsGridData.widthHint = 250;
			detailsGridData.verticalAlignment = SWT.TOP;
			
			Label txChildren = new Label(cCharacterProfile, SWT.WRAP);
			txChildren.setText(character.getChildren());
			txChildren.setBounds(180, 20 + 30 * i, 300, 20);
			txChildren.setForeground(clrWhite);
			txChildren.setLayoutData(detailsGridData);

			i++;
		}

		// quotations
		if (character.getQuotations() != null) {
			GridData labelGridData = new GridData();
			labelGridData.verticalAlignment = SWT.TOP;

			Label lblQuotations = new Label(cCharacterProfile, 0);
			lblQuotations.setText("Quotations: ");
			lblQuotations.setBounds(10, 20 + 30 * i, 160, 20);
			lblQuotations.setForeground(clrWhite);
			lblQuotations.setLayoutData(labelGridData);

			GridData detailsGridData = new GridData();
			detailsGridData.widthHint = 250;
			detailsGridData.verticalAlignment = SWT.TOP;
			
			Label txQuotations = new Label(cCharacterProfile, SWT.WRAP);
			txQuotations.setText(character.getQuotations());
			txQuotations.setBounds(180, 20 + 30 * i, 300, 20);
			txQuotations.setForeground(clrWhite);
			txQuotations.setLayoutData(detailsGridData);

			i++;
		}

		// ethnicity
		if (character.getEthnicity() != null) {
			GridData labelGridData = new GridData();
			labelGridData.verticalAlignment = SWT.TOP;

			Label lblEthnicity = new Label(cCharacterProfile, 0);
			lblEthnicity.setText("Ethnicity: ");
			lblEthnicity.setBounds(10, 20 + 30 * i, 160, 20);
			lblEthnicity.setForeground(clrWhite);
			lblEthnicity.setLayoutData(labelGridData);

			GridData detailsGridData = new GridData();
			detailsGridData.widthHint = 250;
			detailsGridData.verticalAlignment = SWT.TOP;
			
			Label txEthnicity = new Label(cCharacterProfile, SWT.WRAP);
			txEthnicity.setText(character.getEthnicity());
			txEthnicity.setBounds(180, 20 + 30 * i, 300, 20);
			txEthnicity.setForeground(clrWhite);
			txEthnicity.setLayoutData(detailsGridData);

			i++;
		}

		// education
		if (character.getEducation() != null) {
			GridData labelGridData = new GridData();
			labelGridData.verticalAlignment = SWT.TOP;

			Label lblEducation = new Label(cCharacterProfile, 0);
			lblEducation.setText("Education: ");
			lblEducation.setBounds(10, 20 + 30 * i, 160, 20);
			lblEducation.setForeground(clrWhite);
			lblEducation.setLayoutData(labelGridData);

			GridData detailsGridData = new GridData();
			detailsGridData.widthHint = 250;
			detailsGridData.verticalAlignment = SWT.TOP;
			
			Label txEducation = new Label(cCharacterProfile, SWT.WRAP);
			txEducation.setText(character.getEducation());
			txEducation.setBounds(180, 20 + 30 * i, 300, 20);
			txEducation.setForeground(clrWhite);
			txEducation.setLayoutData(detailsGridData);

			i++;
		}

		// Parents
		if (character.getHasPossessed() != null) {
			GridData labelGridData = new GridData();
			labelGridData.verticalAlignment = SWT.TOP;

			Label lblHasPossessed = new Label(cCharacterProfile, 0);
			lblHasPossessed.setText("Has Possessed: ");
			lblHasPossessed.setBounds(10, 20 + 30 * i, 160, 20);
			lblHasPossessed.setForeground(clrWhite);
			lblHasPossessed.setLayoutData(labelGridData);

			GridData detailsGridData = new GridData();
			detailsGridData.widthHint = 250;
			detailsGridData.verticalAlignment = SWT.TOP;
			
			Label txHasPossessed = new Label(cCharacterProfile, SWT.WRAP);
			txHasPossessed.setText(character.getHasPossessed());
			txHasPossessed.setBounds(180, 20 + 30 * i, 300, 20);
			txHasPossessed.setForeground(clrWhite);
			txHasPossessed.setLayoutData(detailsGridData);

			i++;
		}

		// medicalConditions
		if (character.getMedicalConditions() != null) {
			GridData labelGridData = new GridData();
			labelGridData.verticalAlignment = SWT.TOP;

			Label lblMedicalConditions = new Label(cCharacterProfile, 0);
			lblMedicalConditions.setText("Medical Conditions: ");
			lblMedicalConditions.setBounds(10, 20 + 30 * i, 160, 20);
			lblMedicalConditions.setForeground(clrWhite);
			lblMedicalConditions.setLayoutData(labelGridData);

			GridData detailsGridData = new GridData();
			detailsGridData.widthHint = 250;
			detailsGridData.verticalAlignment = SWT.TOP;
			
			Label txMedicalConditions = new Label(cCharacterProfile, SWT.WRAP);
			txMedicalConditions.setText(character.getMedicalConditions());
			txMedicalConditions.setBounds(180, 20 + 30 * i, 300, 20);
			txMedicalConditions.setForeground(clrWhite);
			txMedicalConditions.setLayoutData(detailsGridData);

			i++;
		}

		// dateOfBirth
		if (character.getDateOfBirth() != null) {
			GridData labelGridData = new GridData();
			labelGridData.verticalAlignment = SWT.TOP;

			Label lblDateOfBirth = new Label(cCharacterProfile, 0);
			lblDateOfBirth.setText("Date of Birth: ");
			lblDateOfBirth.setBounds(10, 20 + 30 * i, 160, 20);
			lblDateOfBirth.setForeground(clrWhite);
			lblDateOfBirth.setLayoutData(labelGridData);

			GridData detailsGridData = new GridData();
			detailsGridData.widthHint = 250;
			detailsGridData.verticalAlignment = SWT.TOP;
			
			Label txDateOfBirth = new Label(cCharacterProfile, SWT.WRAP);
			txDateOfBirth.setText(character.getDateOfBirth());
			txDateOfBirth.setBounds(180, 20 + 30 * i, 300, 20);
			txDateOfBirth.setForeground(clrWhite);
			txDateOfBirth.setLayoutData(detailsGridData);

			i++;
		}

		// height
		Label lblHeight = new Label(cCharacterProfile, 0);
		lblHeight.setText("Height: ");
		lblHeight.setBounds(10, 20 + 30 * i, 160, 20);
		lblHeight.setForeground(clrWhite);

		Label txHeight = new Label(cCharacterProfile, 0);
		txHeight.setText(Float.toString(character.getHeight()));
		txHeight.setBounds(180, 20 + 30 * i, 300, 20);
		txHeight.setForeground(clrWhite);

		i++;

		// weight
		Label lblWeight = new Label(cCharacterProfile, 0);
		lblWeight.setText("Weight: ");
		lblWeight.setBounds(10, 20 + 30 * i, 160, 20);
		lblWeight.setForeground(clrWhite);

		Label txWeight = new Label(cCharacterProfile, 0);
		txWeight.setText(Float.toString(character.getWeight()));
		txWeight.setBounds(180, 20 + 30 * i, 300, 20);
		txWeight.setForeground(clrWhite);

		i++;

		// placeslived
		if (character.getPlacesLived() != null) {
			GridData labelGridData = new GridData();
			labelGridData.verticalAlignment = SWT.TOP;

			Label lblPlacesLived = new Label(cCharacterProfile, 0);
			lblPlacesLived.setText("Places Lived: ");
			lblPlacesLived.setBounds(10, 20 + 30 * i, 160, 20);
			lblPlacesLived.setForeground(clrWhite);
			lblPlacesLived.setLayoutData(labelGridData);

			GridData detailsGridData = new GridData();
			detailsGridData.widthHint = 250;
			detailsGridData.verticalAlignment = SWT.TOP;
			
			Label txPlacesLived = new Label(cCharacterProfile, SWT.WRAP);
			txPlacesLived.setText(character.getPlacesLived());
			txPlacesLived.setBounds(180, 20 + 30 * i, 300, 20);
			txPlacesLived.setForeground(clrWhite);
			txPlacesLived.setLayoutData(detailsGridData);

			i++;
		}

		// romanticallyInvolvedWith
		if (character.getRomanticallyInvolvedWith() != null) {
			GridData labelGridData = new GridData();
			labelGridData.verticalAlignment = SWT.TOP;

			Label lblRIW = new Label(cCharacterProfile, 0);
			lblRIW.setText("Romantically Involved With: ");
			lblRIW.setBounds(10, 20 + 30 * i, 160, 20);
			lblRIW.setForeground(clrWhite);
			lblRIW.setLayoutData(labelGridData);

			GridData detailsGridData = new GridData();
			detailsGridData.widthHint = 250;
			detailsGridData.verticalAlignment = SWT.TOP;
			
			Label txRIW = new Label(cCharacterProfile, SWT.WRAP);
			txRIW.setText(character.getRomanticallyInvolvedWith());
			txRIW.setBounds(180, 20 + 30 * i, 300, 20);
			txRIW.setForeground(clrWhite);
			txRIW.setLayoutData(detailsGridData);

			i++;
		}

		cCharacterProfile.setBounds(0, 0, 450, 50 + 30 * i);
		sbCharacterProfile.addListener(SWT.Selection, new Listener() {

			public void handleEvent(Event e) {
				Point location = cCharacterProfile.getLocation();
				location.y = -sbCharacterProfile.getSelection() * ((20 * i) / sbCharacterProfile.getMaximum());
				cCharacterProfile.setLocation(location);
			}
		});

		// reviews group
		Group grReviews = new Group(compCharacterProfile, 0);
		grReviews.setBounds(515, 5, 280, 535);
		grReviews.setForeground(clrWhite);
		grReviews.setBackgroundMode(SWT.INHERIT_FORCE);
		scReviews = new ScrolledComposite(grReviews, SWT.V_SCROLL);
		scReviews.setBounds(5, 75, 275, 458);
		scReviews.setExpandVertical(true);
		cReviews = new Composite(scReviews, 0);
		cReviews.setBounds(0, 0, 280, 1010);
		sbReviews = scReviews.getVerticalBar();
		sbReviews.setVisible(true);
		sbReviews.addListener(SWT.Selection, new Listener() {

			public void handleEvent(Event e) {
				Point location = cReviews.getLocation();
				location.y = -sbReviews.getSelection() * (900 / sbReviews.getMaximum());
				cReviews.setLocation(location);
			}
		});

		Label lblReviews = new Label(compCharacterProfile, 0);
		lblReviews.setForeground(clrWhite);
		lblReviews.setText("Reviews");
		lblReviews.setBounds(535, 5, 65, 30);
		lblReviews.setAlignment(SWT.CENTER);
		lblReviews.moveAbove(grReviews);

		// add a review button
		Button btnReviews = new Button(grReviews, SWT.NONE);
		btnReviews.setImage(new Image(mainDisp, getClass().getClassLoader().getResourceAsStream("view/Assets/survey.png")));
		btnReviews.setToolTipText("Add a Review...");
		btnReviews.setBounds(214, 12, 64, 64);
		btnReviews.addSelectionListener(new SelectionAdapter() {

			@Override
			public void widgetSelected(SelectionEvent e) {
				ReviewPageGUI reviewPopup = new ReviewPageGUI(mainDisp, HomePageGUI.get().getUser(), character);
				reviewPopup.showGUI(mainDisp);
				return;
			}
		});

		// comments group
		Group grComments = new Group(compCharacterProfile, 0);
		grComments.setBounds(5, 340, 500, 200);
		grComments.setForeground(clrWhite);
		grComments.setBackgroundMode(SWT.INHERIT_FORCE);
		scComments = new ScrolledComposite(grComments, SWT.V_SCROLL | SWT.RIGHT_TO_LEFT);
		scComments.setBounds(2, 20, 490, 178);
		scComments.setExpandVertical(true);
		cComments = new Composite(scComments, 0);

		Label lblComments = new Label(compCharacterProfile, 0);
		lblComments.setForeground(clrWhite);
		lblComments.setText("Comments");
		lblComments.setBounds(15, 340, 80, 20);
		lblComments.setAlignment(SWT.CENTER);
		lblComments.moveAbove(grComments);

		// add a comment button
		btnComment = new Button(grComments, SWT.NONE);
		btnComment.setImage(new Image(mainDisp, getClass().getClassLoader().getResourceAsStream("view/Assets/comment.png")));
		btnComment.setToolTipText("Add a Comment...");
		btnComment.setBounds(434, 12, 64, 64);
		btnComment.moveAbove(scComments);
		btnComment.addSelectionListener(new SelectionAdapter() {

			@Override
			public void widgetSelected(SelectionEvent e) {
				NewCommentGUI setDatePopup = new NewCommentGUI(mainDisp, HomePageGUI.get().getUser(), character);
				setDatePopup.showGUI(mainDisp);
				return;
			}
		});

	}

	public Color getBackgroundColor() {
		return cBackgroundColor;
	}

	public void setBackgroundColor(Color cBackgroundColor) {
		this.cBackgroundColor = cBackgroundColor;
	}

	public Font getHeadFont() {
		return fHeadFont;
	}

	public void setHeadFont(Font fHeadFont) {
		this.fHeadFont = fHeadFont;
	}

	public Font getLabelFont() {
		return fLabelFont;
	}

	public void setLabelFont(Font fLabelFont) {
		this.fLabelFont = fLabelFont;
	}

	public Font getButtonFont() {
		return fButtonFont;
	}

	public void setButtonFont(Font fButtonFont) {
		this.fButtonFont = fButtonFont;
	}

	public Display getMainDisp() {
		return mainDisp;
	}

	public void setMainDisp(Display mainDisp) {
		this.mainDisp = mainDisp;
	}

	public LegenCharacter getCharacter() {
		return character;
	}

	public void setCharacter(LegenCharacter character) {
		this.character = character;
	}

	protected void initFonts(Display display) {
		setHeadFont(new Font(display, new FontData("Fiolex Girls", 24, SWT.BOLD)));
		setLabelFont(new Font(display, new FontData("Ariel", 12, SWT.BOLD)));
		setButtonFont(new Font(display, new FontData("Ariel", 10, SWT.BOLD)));

	}

	/**
	 * update the review pane
	 * 
	 * @param review
	 */
	public void updateCharacterReviews(Review review) {
		cReviews.dispose();
		cReviews = new Composite(scReviews, 0);
		cReviews.setBounds(0, 0, 250, 1010);

		final Color clrWhite = new Color(mainDisp, 255, 255, 255);
		for (int i = 0; i < 20; i++) {
			ProgressBar pbTest = new ProgressBar(cReviews, SWT.SMOOTH);
			pbTest.setBounds(85, 30 + 50 * i, 70, 20);
			pbTest.setSelection(review.getAttributeArray()[i] * 10);
			pbTest.setToolTipText(String.valueOf(review.getAttributeArray()[i]));

			Label lblLeftTag = new Label(cReviews, SWT.CENTER);
			lblLeftTag.setText(Review.getBadSide()[i]);
			lblLeftTag.setBounds(0, 30 + 50 * i, 95, 20);
			lblLeftTag.setForeground(clrWhite);

			Label lblnumbers = new Label(cReviews, SWT.CENTER);
			lblnumbers.setText(String.valueOf(review.getAttributeArray()[i]));
			lblnumbers.setBounds(110, 10 + 50 * i, 20, 15);
			lblnumbers.setForeground(clrWhite);

			Label lblRightTag = new Label(cReviews, SWT.CENTER);
			lblRightTag.setText(Review.getGoodSide()[i]);
			lblRightTag.setBounds(150, 30 + 50 * i, 95, 20);
			lblRightTag.setForeground(clrWhite);

		}
	}

	/**
	 * update the comments pane
	 * 
	 * @param comments
	 */
	public void updateCharacterComments(List<Comment> comments) {
		cComments.dispose();
		cComments = new Composite(scComments, SWT.LEFT_TO_RIGHT);
		cComments.setBounds(5, 0, 485, 1000);
		Label lblEmptyLine = new Label(scComments, 0);
		lblEmptyLine.setBounds(0, 0, 520, 10);
		sbComments = scComments.getVerticalBar();
		sbComments.setVisible(true);
		sbComments.addListener(SWT.Selection, new Listener() {

			public void handleEvent(Event e) {
				Point location = cComments.getLocation();
				location.y = -sbComments.getSelection() * (900 / sbComments.getMaximum());
				cComments.setLocation(location);
			}
		});
		int i = 0;
		commentsHeight = 20;
		final Color clrWhite = new Color(mainDisp, 255, 255, 255);
		for (Comment comment : comments) {

			Label lblUserName = new Label(cComments, SWT.CENTER);
			lblUserName.setText(comment.getUserName() + ":");
			lblUserName.setBounds(30, commentsHeight, 100, 20);
			lblUserName.setForeground(clrWhite);

			Label lblComment = new Label(cComments, SWT.LEFT | SWT.WRAP);
			lblComment.setText(comment.getComment());
			int commentHeight = (int) (1 + comment.getComment().length() / 41) * 20;
			lblComment.setBounds(140, commentsHeight, 280, commentHeight);
			lblComment.setForeground(clrWhite);
			Rectangle bounds = lblComment.getBounds();
			commentsHeight += bounds.height;

			Label lblHLine = new Label(cComments, SWT.SEPARATOR | SWT.SHADOW_OUT | SWT.HORIZONTAL);
			lblHLine.setBounds(30, commentsHeight, 470, 10);
			lblHLine.setForeground(clrWhite);
			commentsHeight += 10;
			i++;
		}
		cComments.setBounds(65, 0, 425, commentsHeight);
		lblEmptyLine.moveAbove(cComments);
		sbComments.addListener(SWT.Selection, new Listener() {

			public void handleEvent(Event e) {
				Point location = cComments.getLocation();
				location.y = -sbComments.getSelection() * (commentsHeight / sbComments.getMaximum());
				cComments.setLocation(location);
			}
		});
		btnComment.moveAbove(scComments);
	}

}
